Blockchain technology is at the heart of cryptocurrency, and it is what allows it to be decentralised. It was developed by a group or person called Satoshi Nakamoto as part of the development of Bitcoin, the very first cryptocurrency which will serve as our working example. To this day, and somewhat appropriately, the identity or identities of Satoshi Nakamoto remains unknown.
A fundamental element of the blockchain is cryptography, so we'll cover that first. A cryptographic function is one that can be used to convert input data into an output that is so complex to perform a reverse function on that there is no better known method than simply guessing the input at random – the relevance of this to mining will become clear soon. As you might expect, the mathematics underlying this is extremely complicated; the SHA-256 function that Bitcoin relies on was developed by none other than the NSA. The exact function a cryptocurrency uses can vary, but the principles and characteristics are largely the same.
SHA-256 outputs 256-bit hash values (the length of the input, meanwhile, can be anything), generally represented as 32-character hexadecimal text, where each character is eight bits. There is, of course, a fixed number of possible hash values, but this number is exponentially higher than the number of atoms in the known universe, so the probability of two inputs producing the same output is so low as to make this concern irrelevant. Similarly, while it has not been proven that reverse engineering outputs into inputs is impossible, it is – currently – computationally so difficult that it is considered an extremely secure function.
The blockchain itself is a digital ledger, a history of all transactions that tracks how much people owe and are owed and by inference what they have available to spend, much like banks maintain today. However, it is very different to centrally-maintained, private banking ledgers, because it is both open (anyone can access the full list of transactions) and distributed (the ledger is stored and updated in multiple places – nodes – on a network). At the time of writing, the Bitcoin blockchain is over 160GB, but no single entity owns or controls it. The code that governs it is freely available and open source. In fact, anyone can set themselves up to help maintain the network and blockchain by becoming a node (not the same as mining).
Blocks within the blockchain are lists of transactions, each taking into account the sender(s) and receiver(s), the amount(s) sent, and a timestamp. Validity of transactions is ensured by the nodes in a few ways. Firstly, the sender and receiver; each are represented publicly as 34-character wallet addresses, and it's these that keep the publicly visible transactions pseudonymous. This address is a public key that anyone can send funds to, and each one has an associated private key (effectively the wallet’s password), used to unlock funds for spending and to digitally sign transactions. Transactions are really just messages, and the message cannot be altered without invalidating the digital signature, which prevents tampering. It allows nodes to realise that transactions were indeed sent by the sender without ever actually knowing their private key – clever stuff.
Next is the amount. If you have 20 BTC (the input) and send 10 to bit-tech (thanks!), you actually create two new transactions: 10 to bit-tech and 10 back to yourself (the outputs). The original transaction that gave you 20 BTC is now marked as spent, and you can no longer use it as an input for other transactions (you can use the new transaction of 10 BTC, though). In this way, all transactions can be traced back to the very first and are either spent or unspent, and everyone can check this on the public ledger (see above for an example using blockchain.info). To verify you “have” the amount you want to spend, nodes simply check that you have enough unspent transactions associated with your wallet address included in the blockchain.
As transactions are broadcast to the network, they are assembled into blocks. Every transaction has its own 256-bit hash (via SHA-256) representing the data within, and these are subsequently hashed in a Merkle tree structure to give each block a Merkle root that represents the data of every transaction in that block.
Once you have the Merkle root, it's then necessary to calculate the hash of the block itself. Critically, part of the data required in a block is the hash of the preceding block, and it is this requirement that creates a chain of blocks: a blockchain! Calculating the “correct” hash for a block requires computational power, and this, finally, is where mining comes into play.
October 14 2021 | 15:04
Want to comment? Please log in.